# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html.
# For more examples on how to use CMake, see https://github.com/android/ndk-samples.

# Sets the minimum CMake version required for this project.
cmake_minimum_required(VERSION 3.22.1)

# Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
# Since this is the top level CMakeLists.txt, the project name is also accessible
# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
# build script scope).
project("ffmpegcpp")

#yg 引入库的头文件
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/myLibs/include)

#yg 引入so库
add_library( avcodec-58 SHARED IMPORTED)
#TODO 设置编译的库文件存放的目录
set_target_properties( avcodec-58 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${ANDROID_ABI}/libavcodec-58.so)

add_library( avdevice-58 SHARED IMPORTED)
set_target_properties( avdevice-58 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${ANDROID_ABI}/libavdevice-58.so)

add_library( avfilter-7 SHARED IMPORTED)
set_target_properties( avfilter-7 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${ANDROID_ABI}/libavfilter-7.so)

add_library( avformat-58 SHARED IMPORTED)
set_target_properties( avformat-58 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${ANDROID_ABI}/libavformat-58.so)

add_library( avutil-56 SHARED IMPORTED)
set_target_properties( avutil-56 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${ANDROID_ABI}/libavutil-56.so)

add_library( postproc-55 SHARED IMPORTED)
set_target_properties( postproc-55 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${ANDROID_ABI}/libpostproc-55.so)

add_library( swresample-3 SHARED IMPORTED)
set_target_properties( swresample-3 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${ANDROID_ABI}/libswresample-3.so)

add_library( swscale-5 SHARED IMPORTED)
set_target_properties( swscale-5 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/myLibs/${ANDROID_ABI}/libswscale-5.so)


# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
#
# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
# is preferred for the same purpose.
#
# In order to load a library into your app from Java/Kotlin, you must call
# System.loadLibrary() and pass the name of the library defined here;
# for GameActivity/NativeActivity derived applications, the same library name must be
# used in the AndroidManifest.xml file.
add_library(native-lib SHARED
        # List C/C++ source files with relative paths to this CMakeLists.txt.
        cpp/native-lib.cpp)

# Specifies libraries CMake should link to your target library. You
# can link libraries from various origins, such as libraries defined in this
# build script, prebuilt third-party libraries, or Android system libraries.
target_link_libraries(native-lib
        # List libraries link to the target library
        avcodec-58 avdevice-58 avfilter-7 avformat-58 avutil-56 postproc-55 swresample-3 swscale-5
        android
        log)